package com.qf.bank.controller;


import com.qf.bank.entity.Account;
import com.qf.bank.response.R;
import com.qf.bank.service.ITransactionRecordService;
import com.qf.bank.utils.TokenUtils;
import com.qf.bank.vo.input.SearchHistoryInputVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2022-12-03
 */
@RestController
@RequestMapping("/transactionRecord")
public class TransactionRecordController {

    @Autowired
    private ITransactionRecordService transactionRecordService;

    @RequestMapping("/TransferAccounts")
    public R transferAccounts(HttpServletRequest request, Account account) {
        String userId = TokenUtils.getUserId(request);

        return transactionRecordService.transferAccounts(userId, account);
    }

    @RequestMapping("/searchHistory")
    public R searchHistory(HttpServletRequest request, SearchHistoryInputVo inputVo) {
        String userId = TokenUtils.getUserId(request);

        return transactionRecordService.searchHistory(userId, inputVo);
    }

}
